An integer k in Zn is a generator of Zn if and only if

gcd(n,k) = 1.